﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using Windows . UI . Xaml . Data;

namespace WenceyWang . RichMan4L
{
    public class NumberConverter : IValueConverter
    {
        public object ConvertBack ( object value , Type targetType , object parameter , string language )
        {
            return System . Convert . ToInt64 ( ( value as string ) . Replace ( "$" , "" ) . Replace ( "," , "" ) );
        }

        public object Convert ( object value , Type targetType , object parameter , string language )
        {
            string temp = value . ToString ( );
            temp = temp . Insert ( temp . Length - 3 * ( 1 ) , "," );
            for ( int i = 2 ; i + 1 < temp . Length / 3 ; i++ )
            {
                temp = temp . Insert ( temp . Length - 4 * ( i ) + 1 , "," );
            }
            temp = temp . Insert ( 0 , "$" );
            return temp;
        }
    }
}
